package smecta.client.print.service;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import smecta.client.print.domain.ScpPackage;
import smecta.client.print.mapper.ScpPackageMapper;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class ScpPackageService extends BaseService<ScpPackage>{

    @Autowired
    private ScpPackageMapper scpPackageMapper;


    public List<ScpPackage> getListByStatus(String status){
        List<ScpPackage> list = selectAll();
        if (StringUtils.isBlank(status)){
            return list;
        }
        return list.stream().filter(o->status.equals(o.getTingyong())).collect(Collectors.toList());
    }

    public List<ScpPackage> getListByIdList(List<Long> produceIdList) {
        if (CollectionUtils.isEmpty(produceIdList)){
            return new ArrayList<>();
        }
        Example example = new Example(ScpPackage.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andIn("id",produceIdList);
        return selectByExample(example);
    }
}
